<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <title>Post Message</title>
</head>

<body>
    <input type="button" value="发送消息" onclick="sendMessage()" />
    <div>
        <iframe role="iframe" id="child" src="http://localhost:3000/child.html"></iframe>
    </div>
    <script type="text/javascript">
    function sendMessage() {
        document.getElementById('child').contentWindow.postMessage('ok', 'http://localhost:3000');
    }

    /*window.addEventListener('message', function(e) {
        var color = e.data;
        document.getElementById('color').style.backgroundColor = color;
    }, false);*/
    </script>
</body>

</html>
